package com.yl.auth.controller;

import com.yl.auth.model.entity.Dizhi;
import com.yl.auth.model.entity.YexunXiao;
import com.yl.auth.model.vo.YexunVo;
import com.yl.auth.service.DizhiService;
import com.yl.auth.service.YexunService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "小程序-养老护理-夜巡管理")
@RestController
@RequestMapping("/admin/xiaochengxuyexun")
public class Xiaochengxuyexun {
    @Resource
    private YexunService yexunService;
    @Resource
    private DizhiService dizhiService;
    @GetMapping("/getxiaoyexun")
    @ApiOperation(value = "不分页获取全部夜巡信息")
    public Result getyexuns(@ApiParam("上报人条件查询")String sname, @ApiParam("地址条件查询")String sdizhiname, @ApiParam("巡检上报时间")String sinspectiontime, @ApiParam("巡检状态")Integer sinspectionstatus){
        List<YexunVo> yexunVoList = yexunService.getyexuns(sname, sdizhiname, sinspectiontime, sinspectionstatus);
        return Result.ok(yexunVoList);
    }
    @GetMapping("/getxiaoyexuns/{id}")
    @ApiOperation(value = "根据id查询夜巡信息")
    public Result getxiaoyexuns(@PathVariable Integer id){
        List<YexunVo> yexunVoList = yexunService.getxiaoyexuns(id);
        return Result.ok(yexunVoList);
    }
    @GetMapping("/getzhaungtai/{sinspectionstatus}")
    @ApiOperation(value = "根据状态查询")
    public Result getzhaungtai(@PathVariable Integer sinspectionstatus){
        List<YexunVo> yexunVoList = yexunService.getzhaungtai(sinspectionstatus);
        return Result.ok(yexunVoList);
    }
    @PostMapping("/addyexun")
    @ApiOperation(value = "上报夜巡")
    public Result addyexun(@RequestBody YexunXiao yexunXiao){
        yexunService.save(yexunXiao);
        return Result.ok();
    }
    @ApiOperation(value = "小程序获取全部地址不带分页")
    @GetMapping("/getdizhis")
    public Result getdizhis(){
        List<Dizhi> dizhi = dizhiService.list();
        return Result.ok(dizhi);
    }
    @GetMapping("/getyexuntime")
    @ApiOperation(value = "获取全部时间")
    public Result getyexuntime(){
        List<YexunVo> yexunVoList = yexunService.getyexuntime();
        return Result.ok(yexunVoList);
    }

}
